package com.example.administrator.leargit.utils;

import android.annotation.TargetApi;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;

/**
 * Created by Administrator on 2016/12/22 0022.
 */
public class NotifictionUtils {

    public NotifictionUtils() {
    }

    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    public static void  toNotifiction(Context context, Intent intent, Bundle bundle) {
        int  Iconid=bundle.getInt("ResID");
        String Title=bundle.getString("Title");
        String ContentText=bundle.getString("ContentText");
        String Text=bundle.getString("Text");
        NotificationManager manager= (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
        Notification.Builder builder=new Notification.Builder(context);
        builder.setSmallIcon(Iconid);
        builder.setContentTitle(ContentText);
        builder.setContentText(Text);
        builder.setAutoCancel(true);
        builder.setWhen(System.currentTimeMillis());
        builder.setContentInfo("");
        builder.setTicker("新消息");
        PendingIntent pendingIntent= PendingIntent.getActivity(context,0,intent,PendingIntent.FLAG_CANCEL_CURRENT);
        builder.setContentIntent(pendingIntent);
        Notification notification=builder.build();
        manager.notify(1,notification);
    }



}
